Repository navigation
feat(gateway): integrate the Wave 6 gateway features - #69
Conversation
Defines frozen identity, tenancy, quota and credit authority contracts with explicit adapters and deny-by-default missing authority, plus an administrator-only dry-run preview at /admin/enterprise/preview. ENTERPRISE_PREVIEW_ENABLED defaults to off, and registering the contracts activates nothing.
Adds the context canary scope hook and latency-SLO admission to the named post-authentication order, mounts the usage receipt routes behind a pre-auth 404 gate, and connects the learned cooldown and usage receipt stores to the private D1 endpoints and the reservation reconciliation. Managed dispatch gets read-only latency candidates, dispatch-only canary annotation with per-attempt scanning, cache bypass for opted-in requests and a single upstream cancellation when a policy stops a stream. Native Worker generations run the latency, stream cost and canary policies for Worker-authenticated requests only. Every path is unchanged while its flag is off.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| 🔵 In progress View logs |
multillm-proxy | 546cd41 | Oct 09 2026, 10:40 AM |
SAML_ENABLED (off by default) adds broker-backed dashboard login. The gateway never parses SAML XML: an operator-run broker returns a compact JWS that is verified against pinned RS256 or Ed25519 keys and bound to the issuer, audience, recipient, nonce and browser state. Each request nonce is claimed once, and only an operator-created subject link maps a verified subject to an existing account, with no just-in-time accounts or administrator grants. Native ACS and metadata return 503 saml_native_unavailable. Request state, subject links and audit rows live in D1 (migration 0035).
…webhooks PAYMENTS_ENABLED (off by default) adds POST /v1/payments/checkout, which creates a Stripe Checkout Session for a whole-cent USD amount between $0.50 and $1,000 from an allowlisted return origin, with per-principal daily limits and idempotent replay. POST /v1/payments/webhook verifies the raw body's v1 signature and timestamp, claims each event before any callback, and checks livemode, merchant, currency, amount and session against the stored checkout. Credits are added only through the injected payment callback, once per checkout; refunds and disputes append compensation. The browser return page never credits. Configuration holds secret references only (migration 0038).
…tion TENANT_GOVERNANCE_ENABLED (off by default) applies organisation and team policies to requests in a verified workspace. Model and tool grants intersect with the key's own grants and never widen them. Budgets at every configured level, plus the key's own limits, are reserved together in one atomic operation and settled together; an over-limit level denies the request before dispatch, and an unknown cost keeps its hold at every level. Roles come from a static permission table. Administrators edit policies through /admin/organisations/<org_id>[/teams/<team_id>]/governance with If-Match and audit rows, and /v1/usage gains a workspace breakdown for callers in a workspace. Requests outside a workspace are unchanged (migration 0034).
ORGANISATIONS_ENABLED (off by default) adds a two-level organisation and team hierarchy with stable opaque IDs, roles, caps and deactivation instead of deletion. Administrators manage it under /admin/organisations with If-Match revisions and audit rows. Each account has at most one server-side workspace binding; /v1/workspaces lists the caller's memberships and /v1/workspaces/switch changes the binding only after a membership check. A new first post-authentication hook resolves the verified TenantContext and refuses a missing or deactivated workspace with 404 or 403 before any storage, cache, claim or provider call. Caller headers never choose a workspace. Native Worker generations, knowledge and Realtime resolve the same context, only after the key matches. Accounts without a binding stay in the legacy namespace (migration 0033).
feat(gateway): wire the Wave 7 enterprise features together
3fee165
into
integrate/gateway-waves-1-5
Summary
This branch merges all eight Wave 6 feature branches on top of the Wave 5 integration branch (#60) and wires them together. It is based on
integrate/gateway-waves-1-5, so this diff shows only Wave 6.LATENCY_SLO_MODE,LATENCY_SLO_POLICY_JSONHEDGED_REQUESTS_ENABLED,HEDGED_REQUESTS_POLICY_JSONREALTIME_ENABLED,REALTIME_PROVIDERS_JSON, migration 0029STREAM_COST_BREAKER_ENABLED, migration 0030LEARNED_COOLDOWN_MODE,LEARNED_COOLDOWN_POLICY_JSON, migration 0031USAGE_RECEIPTS_ENABLED,USAGE_RECEIPTS_KEY_ID,USAGE_RECEIPTS_SIGNING_KEY_REF, migration 0032CONTEXT_CANARY_MODE,CONTEXT_CANARY_POLICY_JSONENTERPRISE_PREVIEW_ENABLEDThe four migration PRs form one stack (#62 → #66 → #67 → #68) so each keeps its numbering contiguous. All eight are merged here.
Integration changes
Flask hook order
The named post-authentication order gains two hooks:
app.pyalso mounts the usage receipt routes. While receipts are off, a gate that runs before authentication returns a JSON 404 withCache-Control: no-store, so an unauthenticated caller can't tell whether the routes exist.Storage
learned-cooldown(4 KiB) andusage-receipts(128 KiB).Managed dispatch
services/latency_slo_candidates.pyreturns the reviewed eligible candidates for an auto route. It reads storage only: it never seeds routes, claims a session-lane lease or chooses a health probe or cohort. Whatever it can't resolve has unknown coverage, as the doc says._finish_turnbefore any other finalizer, and inside each hedged attempt with its own context.routes/unified.pyis at 992 lines.Worker
stream_cost_unpricedbefore dispatch.activeUsersByPrefixcaller passesenv, so the cap column is read only while the stream cost breaker is on.learned-cooldownin the control-state dispatcher (get/put, 4 KiB, 404 while its mode is off)./v1/realtime*is handled before every new policy, and its usage still reaches native usage metrics.modelsscope.Known limits
require_coveragereturns 503 for those requests instead of guessing; without it they pass through.cloudflare-worker.mjs,routes/proxy.pyandservices/proxy_service.pyreceived only small call sites.Before merging to main
Four D1 migrations are included:
0029_realtime.sqlthrough0032_usage_receipts.sql. A push to main does not apply them. Apply them first:Apply
0030before settingSTREAM_COST_BREAKER_ENABLED: with the flag on and the column missing, account reads return 503.Tests
tests/test_wave6_registrar.py: hook order, receipt route gating and storage plumbing;tests/test_wave6_managed.py: the managed pipeline through the registered routes;tests/test_wave6_worker.mjs: the native order, private domains, reconciliation receipts and Realtime routing.npm run test:worker: 1,768 passed.npm run test:integration: 7 passed.cf:migrations:checkreports 32 contiguous, additive migrations.test:deploy, free routes, client headers and thewrangler deploy --dry-runbundle all pass.tests/test_frontend_build.mjsfails locally because@tailwindcss/cliis not installed. It fails the same way on main.CI notes
python/nodejobs: the dependency-audit steps fail on every branch, including main. fix(deps): clear the CI dependency audit advisories #42 fixes that.AdmissionCoordinatorDurable Object migration, whichwrangler versions uploadcannot apply. This is expected untilwrangler deployruns on main.